<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <script type="text/javascript">
        function checkYear() {
            var txtYearObj = document.all.txtYear;
            var txtYear = txtYearObj.value
            if((txtYear==null)||(txtYear.length<1)||(txtYear<0)) {
                window.alert("请在文本框中输入正确的年份");
                txtYearObj.focus();
                return;

            }
            if(isNaN(txtYear)) {
                window.alert("年份必须为整形数字");
                txtYearObj.focus();
                return;
            }
            if(isLeapYear(txtYear))
            window.alert(txtYear + "年是闰年！")
            else window.alert(txtYear + "年不是闰年！")

        }
        function isLeapYear(yearVal) {
            if((yearVal%100==0)&&(yearVal%400==0)) return true;
            if(yearVal%4==0) return true;
            return false;
        }
    </script>
    <form action="#" name=frmYear>
        <input type="text" name="txtYear">
        <p>
            请单击按钮
        </p>
        <input type="button" value="click" onclick="checkYear()">
    </form>
</body>
</html>